package cn.pku.eecs.ldn.activity;

import cn.pku.eecs.ldn.R;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.animation.Interpolator;
import android.widget.Scroller;

public class TestScrollerActivity extends Activity {
	private static final String TAG = "TestScrollerActivity";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_test_scroller);

		View view = findViewById(R.id.content);
		view.setOnTouchListener(new SimpleOnTouchListener());
	}

	Scroller mScroller = new Scroller(this);
	
	private void test() {
	}
	
	class SimpleOnTouchListener implements OnTouchListener {

		GestureDetector mGestureDetector = new GestureDetector(
				new GestureDetector.OnGestureListener() {

					@Override
					public boolean onDown(MotionEvent e) {
						// TODO Auto-generated method stub
						return false;
					}

					@Override
					public boolean onFling(MotionEvent e1, MotionEvent e2,
							float velocityX, float velocityY) {
						// TODO Auto-generated method stub
						return false;
					}

					@Override
					public void onLongPress(MotionEvent e) {
						// TODO Auto-generated method stub
						
					}

					@Override
					public boolean onScroll(MotionEvent e1, MotionEvent e2,
							float distanceX, float distanceY) {
						Log.d(TAG, "onScroll(): totalX " + (e2.getX() - e1.getX()) + " totalY " + (e2.getY() - e1.getY()));
						Log.d(TAG, "onScroll(): distanceX " + distanceX + " distanceY " + distanceY);
						return false;
					}

					@Override
					public void onShowPress(MotionEvent e) {
						// TODO Auto-generated method stub
						
					}

					@Override
					public boolean onSingleTapUp(MotionEvent e) {
						// TODO Auto-generated method stub
						return false;
					}
					
				});
		
		@Override
		public boolean onTouch(View v, MotionEvent event) {
			// TODO Auto-generated method stub
			mGestureDetector.onTouchEvent(event);
			return true;
		}
	}

}
